package com.mifengs.mall.util;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.mifengs.commonbase.util.PreferenceUtils;
import com.mifengs.mall.entity.BannerBean;
import com.mifengs.mall.ui.hxcec.GlideCircleTransform;

/**
 * Created by lihaoqi on 2017/11/4.
 */

public class ImageLoadUtil {

    public static void displayImage(Context context, String path, ImageView imageView){
        String photoUrl = PreferenceUtils.getPhotoPath(context);
        Glide.with(context.getApplicationContext())
                .load(photoUrl+path)
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .into(imageView);
    }

    public static void displayImage(Context context, String path, ImageView imageView,int resId ){
        String photoUrl = PreferenceUtils.getPhotoPath(context);
        Glide.with(context.getApplicationContext())
                .load(photoUrl+path)
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .placeholder(resId)
                .into(imageView);
    }


    public static void displayFitImage(Context context, String path, ImageView imageView){
        String photoUrl = PreferenceUtils.getPhotoPath(context);
        Glide.with(context.getApplicationContext())
                .load(photoUrl+path)
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .fitCenter()
                .into(imageView);
    }

    public static void glideRoundImage(Context context, String path, ImageView imageView){
        String photoUrl = PreferenceUtils.getPhotoPath(context);
        Glide.with(context.getApplicationContext())
                .load(photoUrl+path)
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .centerCrop()
                .transform(new GlideCircleTransform(context))
                .into(imageView);
    }


}
